#pragma once
#define    RET_OK nullptr

#include <string>
#include <vector>
#include <cstdio>
#include <opencv2/opencv.hpp>
#include "onnxruntime_cxx_api.h"


class OrtLayerSeg
{
public:
	OrtLayerSeg();

	~OrtLayerSeg();

public:
	// 供类外部调用的运行函数
	char* RunSession(cv::Mat& iImg, std::vector<int>& layerSuface, cv::Mat& outputImg);

private:
	// 配置onnx，cuda等
	char* CreateSession();
	// 数据blob，拉直成一维的
	template<typename T>
	char* BlobFromImage(cv::Mat& iImg, T& iBlob)
	// 做pad填充或者归一化等
    char* PreProcess(cv::Mat& iImg, std::vector<int>& ImgSize, cv::Mat& oImg);
	// 模型推理，输出数据解析
    template<typename N>
    char* TensorProcess(cv::Mat& iImg, N& blob, std::vector<int64_t>& inputNodeDims,
        std::vector<int>& layerSuface, cv::Mat& outputImg);

private:
    Ort::Env env;
    Ort::Session* session;
    Ort::RunOptions options;
	// 输入输出层名已知，直接赋值
    std::vector<const char*> inputNodeNames = {'input_1'};
    std::vector<const char*> outputNodeNames = {'activation_22'};
    
    const ORTCHAR_T* modelPath = L"./exportedModel.onnx";
    std::vector<int> imgSize;
    bool cudaEnable = true;
    int logSeverityLevel = 3;
    int intraOpNumThreads = 1;
};
